import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import App from './App.vue'
import router from './router'
import './styles/theme.css'

// 打印环境信息
console.log('当前环境:', import.meta.env.MODE)
console.log('基础URL:', import.meta.env.BASE_URL)

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(ElementPlus)

// 错误处理
app.config.errorHandler = (err) => {
  console.error('全局错误:', err)
}

// 确保挂载点存在
if (!document.querySelector('#app')) {
  document.body.innerHTML = '<div id="app"></div>'
  console.warn('手动创建了#app挂载点')
}

app.mount('#app')

console.log('应用初始化完成')